
<?xml version="1.0" encoding="UTF-8"?>
<!--
		To change this template, choose Tools | Templates
		and open the template in the editor.
		-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>
	<title>Course Status Update</title>
</h:head>
<f:view>
	<h:body>
		<ui:composition template="../includes/template.xhtml">
			<ui:define name="mainbody">
				<center>

					<p:panel header="Course Status Update" style="min-height: 550px"
						styleClass="prime_panel">


						<p:growl id="growl" showDetail="true" sticky="false"
							autoUpdate="true" showSummary="false" />
						<center>
							<h:form id="form">
								<p:dataTable style="width: 50%" id="courses" var="course"
									value="#{courseStatusUpdateBean.courseModel}" paginator="true"
									rows="10" paginatorPosition="bottom"
									selection="#{courseStatusUpdateBean.selectedCoursesList}">

									<p:column selectionMode="multiple" style="width:18px" />

									<p:column headerText="Course Code" style="width:25%">
				            #{course.courseCode}  
				        </p:column>

									<p:column headerText="Course Title" filterBy="#{course.title}"
										style="width:50%">
				            #{course.title}  
				        </p:column>

									<p:column id="status" headerText="Status" style="width:25%">
										<center>
											#{course.currentStatus eq true ? "Offered" : "Not Offered"}
										</center>
									</p:column>

									<f:facet name="footer">
										<p:commandButton id="multiViewButton" value="Change Status"
											update=":form:displayMulti"
											oncomplete="multiCourseDialog.show()" />
									</f:facet>
								</p:dataTable>

								<p:dialog id="multiDialog" header="Selected Courses"
									widgetVar="multiCourseDialog" showEffect="fade"
									hideEffect="explode">

									<p:dataList id="displayMulti"
										value="#{courseStatusUpdateBean.selectedCoursesList}"
										var="selectedCourse">
				            Name: #{selectedCourse.title} currently #{selectedCourse.currentStatus eq true ? "Offered" : "Not Offered"} for classes
				        </p:dataList>

									<table>
										<tr>
											<td><h:outputLabel>Change status to:</h:outputLabel>
											</td>
											<td><p:selectOneRadio id="options"
													value="#{courseStatusUpdateBean.newStatus}">
													<f:selectItem itemLabel="Offered" itemValue="true" />
													<br />
													<f:selectItem itemLabel="Not Offered" itemValue="false" />
												</p:selectOneRadio></td>
										</tr>
									</table>
									<p:commandButton id="submit" value="Update" type="submit"
										ajax="false" action="#{courseStatusUpdateBean.perform}" />
								</p:dialog>
							</h:form>
						</center>
					</p:panel>
				</center>
			</ui:define>
		</ui:composition>
	</h:body>
</f:view>
</html>
